package com.code.leetcode.offer;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/6 14:03
 */
public class The60_dp {

    public double[] twoSum(int n) {
        double dp[][] = new double[n + 1][6 * n + 1];
        double all = Math.pow(6, n);
        dp[0][0] = 1;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= 6 * i; j++) {
                for (int k = 1; k <= Math.min(j, 6) ; k++) {
                    dp[i][j] += dp[i - 1][j - k];
                }
            }
        }
        double[] rtns = new double[n * 5 + 1];
        for (int i = n; i <= n * 6; i++) {
            rtns[i - n] = dp[n][i] / all;
        }
        return rtns;
    }

}
